<!--- ========================================================================== --->
<!--- Group Approval Main                                                        --->
<!--- by Maan 11302007 (part of Group Approval eTask application)                --->
<!--- ========================================================================== --->
<SCRIPT>
function SetRelationField(sFromValue, sToValue, sAssignValue, sRelatedFld, sDefault, oField) {
var aFrom, aTo, aAssign, nLen, nCnt, lInBetween=false

	aFrom=sFromValue.split(",")
	aTo=sToValue.split(",")
	aAssign=sAssignValue.split(",")
	nLen=aFrom.length

	for (nCnt=0; nCnt < nLen; nCnt++) {
		if (
			 (aFrom[nCnt] == "" && oField.value <= aTo[nCnt]) ||
			 (aTo[nCnt] == "" && oField.value >= aFrom[nCnt]) ||
			 (aFrom[nCnt] <= oField.value && oField.value <= aTo[nCnt])
		   )
		{
			eval("document.frmBatchApp.edt" + sRelatedFld + ".value='" + aAssign[nCnt] + "'")
			lInBetween=true
			break
		}
	}

	if (!lInBetween && sDefault != "")
		eval("document.frmBatchApp.edt" + sRelatedFld + ".value='" + sDefault + "'")
}
function CheckeFormDate(oDate, dCutOff, sLateAppsMode) {
var dDate1, dDate2, lReturn=true

	with (oDate) {
		if (value != "" && !CheckDate(oDate)) {
			//alert("Invalid Date")
			value=""
			lReturn=false
		} else
			if (dCutOff != "") {
				dDate1=new Date(value)
				dDate2=new Date(dCutOff)

				if (sLateAppsMode == "1" && dDate1.valueOf() <= dDate2.valueOf()) {
					alert("Late Application is not accepted.")
					value=""
					lReturn=false
				} else
					if (sLateAppsMode == "2" && dDate1.valueOf() >= dDate2.valueOf()) {
						alert("Advance Application is not accepted.")
						value=""
						lReturn=false
					}
			}
	}

return(lReturn)
}
function CheckDigit(sValidKey, oInput, lExceptKey) {
	var sFld_Value=oInput.value, sKey=sFld_Value.charAt(sFld_Value.length - 1);
	var thelExceptKey = false;
	var nValue;
	if (lExceptKey) {
		thelExceptKey = lExceptKey;
	}

	lExpr=(sValidKey.indexOf(sKey) == -1)
	lExpr=(thelExceptKey) ? (!lExpr) : (lExpr)
	if (lExpr) {
		sFld_Value=sFld_Value.substring(0,sFld_Value.length - 1)
		oInput.value=sFld_Value
	}
}
function validateMasked(fld,msk) {

		var ln = msk.length,
		msk_=""
		x=0,y=0,
		fldVal = fld.value,
		fldNewVal="",
		mskChr="",nValue=0,nAscii=0,sType="",sep="",sTmp="",sTmpVal="";
		for(x=0;x<msk.length;x++) {
		mskChr = msk.charAt(x);
		nValue=parseInt(mskChr);

		if (mskChr == "#") {
			sType = "D";
		}
		else {
			if (isNaN(nValue)) {
				nAscii = mskChr.charCodeAt(0);
				if ((nAscii >= 65 && nAscii <= 90) || (nAscii >= 97 && nAscii <= 122))
					sType = "A";
				else {
					sType = "S";
					sep = sep + mskChr + "|||";
				}
			}
			else
				sType = "D";
		}
		
		msk_ = msk_ + sType;

		}
		
		sep = sep.substring(0,sep.length-1);
		sep = sep.split("|||");

		for(x=0;x<sep.length-1;x++) {

		y = fldVal.indexOf(sep[x]);

		while (y != -1) {
			fldVal = fldVal.replace(sep[x],"");
			y = fldVal.indexOf(sep[x]);
		}

			if (fldVal.indexOf(sep[x]) != -1) {
				fldVal = fldVal.replace(sep[x],"");
			}

		}

		y=0;
    	 sTmpVal= fldVal;
     	 //remove the separator in original vallue
		for(x=0;x<msk_.length;x++) {
			mskChr = msk_.charAt(x);
			if (mskChr == "S") {
				sTmpVal = sTmpVal.replace(msk.charAt(x),"");
			}
		}
		//create the mask value
		for(x=0;x<msk_.length;x++) {
			mskChr = msk_.charAt(x);
			nValue=parseInt(sTmpVal.charAt(y));
			if ((mskChr == "A") && (isNaN(nValue))){
				fldNewVal = fldNewVal + sTmpVal.charAt(y);
				y++;
			}
			else if ((mskChr == "D") && !(isNaN(nValue)) ) {
				fldNewVal = fldNewVal + sTmpVal.charAt(y);
				y++;
			}
			else if (mskChr == "S") {
				fldNewVal = fldNewVal + msk.charAt(x);
		
			}
		}
		if ((sep.length) == (fldNewVal.length)) {
		    	fld.value = ""
		}
		else {
		    	fld.value  = fldNewVal;
		}
}
function chkBoxEnable(){
	if (frmBatchApp.chkEmps.length == undefined) {
		if (document.frmBatchApp.chkEmps.checked == true){
			document.frmBatchApp.btnAddToRecord.disabled = false;
			document.frmBatchApp.btnDeleteEmployee.disabled = false;
			document.frmBatchApp.btnViewReturned.disabled = false;
		}
		else{
			document.frmBatchApp.btnAddToRecord.disabled = true;
			document.frmBatchApp.btnDeleteEmployee.disabled = true;
			document.frmBatchApp.btnViewReturned.disabled = true;
		}
	}
	else{
		var max = frmBatchApp.chkEmps.length;
		for (var idx = 0; idx <= max; idx++) {
		if ((eval("document.frmBatchApp.chkEmps[" + idx + "].checked") == true) || (document.frmBatchApp.chkAllEmps.checked == true)) {
			document.frmBatchApp.btnAddToRecord.disabled = false;
			document.frmBatchApp.btnDeleteEmployee.disabled = false;
			break;
			}
		else{
			document.frmBatchApp.btnAddToRecord.disabled = true;
			document.frmBatchApp.btnDeleteEmployee.disabled = true;
			document.frmBatchApp.chkAllEmps.checked = false;
		   }
		
		}
	}
}
function chkBoxEnable2(){
	if (frmBatchApp.chkEmps.length == undefined) {
		if (document.frmBatchApp.chkEmps.checked == true){
			document.frmBatchApp.btnAddToRecord.disabled = false;
			document.frmBatchApp.btnDeleteEmployee.disabled = false;
			document.frmBatchApp.btnViewReturned.disabled = false;
		}
		else{
			document.frmBatchApp.btnAddToRecord.disabled = true;
			document.frmBatchApp.btnDeleteEmployee.disabled = true;
			document.frmBatchApp.btnViewReturned.disabled = true;
		}
	}
	else{
		var max = frmBatchApp.chkEmps.length;
		for (var idx = 0; idx <= max; idx++) {
		if ((eval("document.frmBatchApp.chkEmps[" + idx + "].checked") == true) || (document.frmBatchApp.chkAllEmps.checked == true)) {
			document.frmBatchApp.btnAddToRecord.disabled = false;
			document.frmBatchApp.btnDeleteEmployee.disabled = false;
			document.frmBatchApp.btnViewReturned.disabled = false;
			break;
			}
		else{
			document.frmBatchApp.btnAddToRecord.disabled = true;
			document.frmBatchApp.btnDeleteEmployee.disabled = true;
			document.frmBatchApp.chkAllEmps.checked = false;
			document.frmBatchApp.btnViewReturned.disabled = true;
		   }
		
		}
	}
}
function chkEnableRecbtn(){
	if (frmBatchApp.chkRecs.length == undefined) {
		if (document.frmBatchApp.chkRecs.checked == true){
			document.frmBatchApp.btnUpdateRecs.disabled = false;
			document.frmBatchApp.btnDeleteRecs.disabled = false;
		}
		else{
			document.frmBatchApp.btnUpdateRecs.disabled = true;
			document.frmBatchApp.btnDeleteRecs.disabled = true;
		}
	}
	else{
		var max = frmBatchApp.chkRecs.length;
		for (var idx = 0; idx <= max; idx++) {
		if ((eval("document.frmBatchApp.chkRecs[" + idx + "].checked") == true) || (document.frmBatchApp.chkEmps.checked == true)) {
			document.frmBatchApp.btnUpdateRecs.disabled = false;
			document.frmBatchApp.btnDeleteRecs.disabled = false;
			break;
			}
		else{
			document.frmBatchApp.btnUpdateRecs.disabled = true;
			document.frmBatchApp.btnDeleteRecs.disabled = true;
			document.frmBatchApp.chkAllRecs.checked = false;
		   }
		
		}
	}
}
function chkBoxAll(field){
	var count = field.length;
	var checkall;
	if (frmBatchApp.chkAllEmps.checked == true){
		checkall = true;
		document.frmBatchApp.btnAddToRecord.disabled = false;
		document.frmBatchApp.btnDeleteEmployee.disabled = false;
	}
	else{
		checkall = false;
		document.frmBatchApp.btnAddToRecord.disabled = true;
		document.frmBatchApp.btnDeleteEmployee.disabled = true;
	}

	if (count == undefined){
		count = "1";
		field.checked = checkall;
	}
	else{
		for (var x = 0; x < count; x++) {field[x].checked = checkall;}
	}
}
function chkBoxAll2(field){
	var count = field.length;
	var checkall;
	if (frmBatchApp.chkAllEmps.checked == true){
		checkall = true;
		document.frmBatchApp.btnAddToRecord.disabled = false;
		document.frmBatchApp.btnDeleteEmployee.disabled = false;
		document.frmBatchApp.btnViewReturned.disabled = false;
	}
	else{
		checkall = false;
		document.frmBatchApp.btnAddToRecord.disabled = true;
		document.frmBatchApp.btnDeleteEmployee.disabled = true;
		document.frmBatchApp.btnViewReturned.disabled = true;
	}

	if (count == undefined){
		count = "1";
		field.checked = checkall;
	}
	else{
		for (var x = 0; x < count; x++) {field[x].checked = checkall;}
	}
}
function chkBoxAllRecs(field){
	var count = field.length;
	var checkall;
	if (frmBatchApp.chkAllRecs.checked == true){
		checkall = true;
		document.frmBatchApp.btnUpdateRecs.disabled = false;
		document.frmBatchApp.btnDeleteRecs.disabled = false;
	}
	else{
		checkall = false;
		document.frmBatchApp.btnUpdateRecs.disabled = true;
		document.frmBatchApp.btnDeleteRecs.disabled = true;
	}

	if (count == undefined){
		count = "1";
		field.checked = checkall;
	}
	else{
		for (var x = 0; x < count; x++) {field[x].checked = checkall;}
	}
}
function chkBoxAllEmps(fieldemps){
	var count = fieldemps.length;
	var checkall;
	if (frmBatchApp.chkAll.checked == true){checkall = true;}
	else{checkall = false;}

	if (count == undefined){
		count = "1";
		fieldemps.checked = true;
	}
	else{
		for (var x = 0; x < count; x++) {fieldemps[x].checked = checkall;}
	}
}
function validateReqField(){
	if (document.frmBatchApp.edtBatchDesc.value = ""){
		alert ("Please fill out Description field.");
		return false;
	}
	else {
		return true;
	}
}
/*
function capturedate(){
	<CFOUTPUT>
		window.open("#client.domain#etasks/applications/groupapplication/_daterange.cfm", "iBOS/e Attendance","width=400,height=150,ScrollBars=Yes,Resizable=Yes");
	</CFOUTPUT>
}*/
</SCRIPT>
<script language="JavaScript1.2" src="#client.common_path#CheckDate.js"></script>
	<script language="JavaScript1.2" src="#client.common_path#CheckValue.js"></script>
	<script language="JavaScript1.2" src="#client.common_path#js_currency.js">
</script>
<CFPARAM NAME="sWarn" DEFAULT="">
<CFPARAM NAME="sMess" DEFAULT="">
<CFSET sFieldWthFormat="">
<CFINCLUDE TEMPLATE="#client.common_path#popdate.cfm">
<CFQUERY NAME="GetData" DATASOURCE="#client.company_dsn#">
	SELECT B.*, A.ISBADGE AS ISBADGE, A.FLDFILTER AS FLDFILTER, A.FLDDATES AS FLDDATES, A.NOTIFYCREATOR AS NOTIFYCREATOR,A.BATCHID
	FROM ECRGBATCHAPPLY A, ECRGFORMS B
	WHERE 	(A.BATCHID = B.FORMCODE) AND
		(A.BATCHID = '#GetForm.FORMCODE#')
</CFQUERY>
<CFQUERY NAME="GetData2" DATASOURCE="#client.company_dsn#">
	SELECT B.ROUTEID, A.PERSONNELIDNO, A.DOCNUMBER
	FROM ECINBATCHEMPS A, ECINBATCHDTL B
	WHERE 	(A.BATCHID = B.BATCHID) AND
		(A.DOCNUMBER = B.DOCNUMBER) AND
		(A.BATCHID = '#GetForm.FORMCODE#')
		<CFIF isDefined("url.view") OR isDefined("url.Docnumber")> AND (A.DOCNUMBER = '#url.DOCNUMBER#')
		<CFELSEIF isDefined("form.hidDocnumber")> AND (A.DOCNUMBER = '#form.hidDocnumber#')
		<CFELSEIF isDefined("form.edtBatchNumber")> AND (A.DOCNUMBER = '#form.edtBatchNumber#')
		</CFIF>
</CFQUERY>
<CFQUERY NAME="QueryView" DATASOURCE="#client.company_dsn#">
	SELECT DISTINCT(C.DOCNUMBER), C.DESCRIPTION AS BATCHDESC , C.ROUTED
	FROM ECRGBATCHAPPLY A, ECINBATCHAPPLY C
	WHERE 	(A.BATCHID = C.BATCHID) AND
		(C.BATCHID = '#GetData.FORMCODE#')
		<CFIF isDefined("form.Filter") AND form.edtValFilter NEQ "">
			AND #form.CMBSORT# LIKE '%#form.edtValFilter#%'
		</CFIF>
		<CFIF LCase(client.userid) NEQ "admin">
			AND C.RECCREATEDBY = '#client.userid#'
		</CFIF>
	GROUP BY C.DOCNUMBER, C.DESCRIPTION, C.ROUTED
	ORDER BY C.DOCNUMBER DESC
</CFQUERY>

<CFSET sBtnVal = "Update">
<CFIF GetData2.RECORDCOUNT NEQ 0>
	<!---<CFQUERY NAME="qryReturned" DATASOURCE="#client.company_dsn#">
		SELECT DISTINCT(B.DOCNUMBER) AS DOCNUMBER, A.ROUTEID FROM #GetData.TABLENAME_FK# A, ECINBATCHEMPS B
		WHERE (A.ROUTEID = B.ROUTEID) AND A.ROUTEID IN (#QuotedValueList(GetData.ROUTEID)#) AND A.APPROVED = 'R'
	</CFQUERY>--->
	<CFQUERY NAME="qryReturned" DATASOURCE="#client.company_dsn#">
		SELECT DISTINCT DOCNUMBER, PERSONNELIDNO FROM ECINBATCHEMPS
		WHERE 	DOCNUMBER IN 
			(SELECT DISTINCT A.DOCNUMBER FROM ECINBATCHDTL A, #GetForm.TABLENAME_FK# B
			 WHERE (A.ROUTEID = B.ROUTEID) AND B.APPROVED = 'R')
		AND
			PERSONNELIDNO IN 
			(SELECT DISTINCT A.PERSONNELIDNO FROM ECINBATCHDTL A, #GetData.TABLENAME_FK# B
			 WHERE (A.ROUTEID = B.ROUTEID) AND B.APPROVED = 'R')
		AND 
			BATCHID = '#GetData.FORMCODE#'
	</CFQUERY>
</CFIF>
<CFQUERY NAME="GetLevel" DATASOURCE="#client.global_dsn#">
	SELECT A.LEVELID, B.COLUMNNAME, B.COLUMNDESC
	FROM GRGBOSETABLE A, GRGBOSETABLEFIELDS B
	WHERE A.TABLENAME = B.TABLENAME AND B.HIDEONBROWSE = 'N' AND B.TABLENAME = '#GetData.TABLENAME_FK#'
</CFQUERY>
<CFMODULE TEMPLATE="#client.common_path#cfm_leveldsn.cfm" DBLEVEL="#GetLevel.LEVELID#">
<CFIF GetData.ISBADGE EQ "N">
	<CFSET stheID = "PERSONNELIDNO">
	<CFSET stheIDDesc = "Personnel ID No">
<CFELSE>
	<CFSET stheID = "PERSONNELBADGENO">
	<CFSET stheIDDesc = "Personnel Badge No">
</CFIF>
<CFOUTPUT>
	<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm" REMOVEURL="sWarn">
	<FORM METHOD="POST" NAME="frmBatchApp" ACTION="#getFileFromPath(getBaseTemplatePath())#?#urlVariables#">
</CFOUTPUT>
	<CFIF isDefined("form.refresh")>
		<SCRIPT LANGUAGE="JAVASCRIPT">
			<CFOUTPUT>
				<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm" REMOVEURL="EDIT,RETURNED,VIEW,SWARN,SMESS,DOCNUMBER,ROUTEID,EMPLOYEEID">
				<CFSET sUrlVars = urlVariables>
				location.href = "#getFileFromPath(getBaseTemplatePath())#?#sUrlVars#";
			</CFOUTPUT>
		</SCRIPT>
	<CFELSEIF isDefined("url.delete")>
		<!--- confirm then delete --->
		<CFTRY>
			<CFQUERY NAME="deleteDtl" DATASOURCE="#client.company_dsn#">
				DELETE
				FROM ECINBATCHDTL
				WHERE BATCHID = '#getform.formcode#' AND DOCNUMBER = '#url.docnumber#'
			</CFQUERY>
			<CFQUERY NAME="deleteEmps" DATASOURCE="#client.company_dsn#">
				DELETE
				FROM ECINBATCHEMPS
				WHERE BATCHID = '#getform.formcode#' AND DOCNUMBER = '#url.docnumber#'
			</CFQUERY>
			<CFQUERY NAME="deleteMaster" DATASOURCE="#client.company_dsn#">
				DELETE
				FROM ECINBATCHAPPLY
				WHERE BATCHID = '#getform.formcode#' AND DOCNUMBER = '#url.docnumber#'
			</CFQUERY>
			<CFTRANSACTION ACTION="COMMIT"/>
			<CFCATCH TYPE="Database">
				<CFSET sWarn = "#CFCATCH.MESSAGE#" & "<BR>" & "#CFCATCH.DETAIL#">
				<CFTRANSACTION ACTION="ROLLBACK"/>
			</CFCATCH>
		</CFTRY>
		<CFSET sMess = "Record(s) successfully deleted.">
		<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm" REMOVEURL="sWarn,sMess,edit,employeeid,view,delete,docnumber">
		<CFLOCATION url="#getFileFromPath(getBaseTemplatePath())#?#urlVariables#&sMess=#sMess#&sWarn=#sWarn#">
	<CFELSEIF isDefined("form.btnBackMenu")>
		<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm" REMOVEURL="sWarn,edit,employeeid,view">
		<CFLOCATION url="#getFileFromPath(getBaseTemplatePath())#?#urlVariables#&sWarn=#sWarn#">
	<CFELSEIF isDefined("form.btnRoute") OR isDefined("form.btnUpdateFF") OR isDefined("form.btnRouteForms")>
		<CFIF isDefined("form.btnRoute")>
			<CFQUERY NAME="qryChkDtls" DATASOURCE="#client.company_dsn#">
				SELECT A.* FROM ECINBATCHDTL A, ECINBATCHEMPS B
				WHERE 	(A.BATCHID = B.BATCHID) AND
					(A.DOCNUMBER = B.DOCNUMBER) AND
					(A.DOCNUMBER = '#form.edtBatchnumber#') AND
					(A.BATCHID = '#getform.formcode#')
			</CFQUERY>
			<CFIF qryChkDtls.RECORDCOUNT>
				<CFINCLUDE TEMPLATE="batchAppRoute.cfm">
			</CFIF>
		<CFELSE>
			<CFINCLUDE TEMPLATE="batchAppRoute.cfm">
		</CFIF>
	<CFELSEIF (isDefined("form.btnAddEmployees") AND NOT isDefined("form.BTNADDEMPS"))><!--- removed " OR isDefined("form.selGroup")" by Maan 02172008 --->
		<CFINCLUDE TEMPLATE="batchAppAddEmp.cfm">	
	<CFELSEIF isDefined("url.edit") OR isDefined("url.view") OR isDefined("form.chkEmp") OR isDefined("form.btnAdd") OR isDefined("form.btnAddToRecord") OR isDefined("form.btnViewReturned")>
		<CFIF isDefined("url.edit") AND url.edit EQ "true" AND isDefined("url.view")>
			<SCRIPT LANGUAGE="JAVASCRIPT">
				<CFOUTPUT>
					<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm" REMOVEURL="VIEW,RETURNED">
					<CFSET sUrlVars = urlVariables>
					location.href = "#getFileFromPath(getBaseTemplatePath())#?#sUrlVars#";
				</CFOUTPUT>
			</SCRIPT>
		<CFELSEIF isDefined("url.edit") AND url.edit EQ "master" AND isDefined("url.smess")>
			<SCRIPT LANGUAGE="JAVASCRIPT">
				<CFOUTPUT>
					<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm" REMOVEURL="SMESS,SWARN">
					<CFSET sUrlVars = urlVariables>
					location.href = "#getFileFromPath(getBaseTemplatePath())#?#sUrlVars#";
				</CFOUTPUT>
			</SCRIPT>
		<CFELSEIF isDefined("url.view") AND url.view EQ "master" AND (isDefined("url.edit") OR isDefined("url.returned"))>
			<SCRIPT LANGUAGE="JAVASCRIPT">
				<CFOUTPUT>
					<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm" REMOVEURL="EDIT,RETURNED">
					<CFSET sUrlVars = urlVariables>
					location.href = "#getFileFromPath(getBaseTemplatePath())#?#sUrlVars#";
				</CFOUTPUT>
			</SCRIPT>
		<CFELSEIF isDefined("form.add")> 
			<SCRIPT LANGUAGE="JAVASCRIPT">
				<CFOUTPUT>
					<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm" REMOVEURL="SWARN,SMESS">
					<CFSET sUrlVars = urlVariables>
					location.href = "#getFileFromPath(getBaseTemplatePath())#?#sUrlVars#";
				</CFOUTPUT>
			</SCRIPT>
		</CFIF>
		<CFINCLUDE TEMPLATE="batchAppEdit.cfm">
	<CFELSEIF (NOT isDefined("form.Add") AND NOT isDefined("form.btnAddEmps") AND NOT isDefined("url.view"))><!--- browse --->
		<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE = "Browse Group Applications">
			<CFOUTPUT><CFIF sWarn NEQ "">
				<FONT COLOR="RED"><B>&nbsp;#sWarn#<br></B></FONT>
			<CFELSEIF isDefined("url.sWarn") AND url.sWarn NEQ ""><FONT COLOR="RED"><B>&nbsp;#url.sWarn#<br></B></FONT>
			<CFELSEIF isDefined("url.sMess") AND url.sMess NEQ ""><B>&nbsp;#url.sMess#</B><br>
			<CFELSEIF sMess NEQ "" OR (isDefined("url.smess") AND url.smess NEQ "")>
				<B>&nbsp;#sMess#<br>
			</CFIF></CFOUTPUT>	
			<CFINCLUDE TEMPLATE="_toolbar.cfm">
			<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=0 WIDTH="100%">
				<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm" REMOVEURL="sWarn">
				<CFIF QueryView.RECORDCOUNT>
					<CFOUTPUT><TR HEIGHT=18 BGCOLOR="#client.color_tblhead#"></CFOUTPUT>
						<TD WIDTH="4%" ALIGN="CENTER">&nbsp;</TD>
						<TD CLASS="boldwhite" WIDTH="15%" ALIGN="LEFT">&nbsp;Docnumber</TD>
						<TD CLASS="boldwhite" WIDTH="15%" ALIGN="LEFT">&nbsp;Description</TD>
						<TD CLASS="boldwhite" WIDTH="3%" ALIGN="LEFT">&nbsp;Routed</TD>
					</TR>
					<CFOUTPUT QUERY="QueryView" MAXROWS="#OnEachPage#" STARTROW="#form.startrow#">
						<TR BGCOLOR=<CFIF CurrentRow Mod 2>"#client.color_tblset2#"<CFELSE>"#client.color_tblset1#"</CFIF> VALIGN="top">
							<TD ALIGN="CENTER">
								<CFIF QueryView.ROUTED NEQ "Y">
									<CFIF qryReturned.RECORDCOUNT AND ListFindNoCase("#ValueList(qryReturned.DOCNUMBER)#",DOCNUMBER)>
										<a class="regular11" href="#getFileFromPath(getBaseTemplatePath())#?#urlVariables#&DOCNUMBER=#QueryView.DOCNUMBER#&edit=master&returned=master">edit</a>
									<CFELSE>
										&nbsp;&nbsp;<a class="regular11" href="#getFileFromPath(getBaseTemplatePath())#?#urlVariables#&DOCNUMBER=#QueryView.DOCNUMBER#&edit=master">edit</a>
									</CFIF>
								</CFIF>
								<a class="regular11" href="#getFileFromPath(getBaseTemplatePath())#?#urlVariables#&DOCNUMBER=#QueryView.DOCNUMBER#&view=master">view</a>
								<CFIF QueryView.ROUTED NEQ "Y">
									<a class="regular11" href="#getFileFromPath(getBaseTemplatePath())#?#urlVariables#&DOCNUMBER=#QueryView.DOCNUMBER#&delete=" ONCLICK="javascript:return confirmThis('Delete this record?');">delete</a>
								</CFIF>
							</TD>
							<TD WIDTH="15%" ALIGN="LEFT">&nbsp;#QueryView.DOCNUMBER#</TD>
							<TD WIDTH="15%" ALIGN="LEFT">&nbsp;#QueryView.BATCHDESC#</TD>
							<TD WIDTH="3%" ALIGN="CENTER">&nbsp;#QueryView.ROUTED#</TD>
						</TR>
					</CFOUTPUT>
					<CFOUTPUT>
					<TR BGCOLOR="#client.color_tblfoot#">
						<TD CLASS="boldwhite" HEIGHT=18 COLSPAN="5">&nbsp;Records: #form.startrow# - #EndRow# of #QueryView.RECORDCOUNT#</TD>
					</TR>
					</CFOUTPUT>
				<CFELSE>
					<TR>
						<TD>&nbsp;&nbsp;<b>No records found in the current filter.</b></TD>
					</TR>
				</CFIF>
			</TABLE>
	<CFELSE>
		<CFSET isRequired = "false">
		<CFSET isReadonly = "false">
		<CFSET isDisable = "">
		<CFSET btnDisable = "">
		<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE = "Add New Group Application">
			<CFOUTPUT>
				<CFIF sWarn NEQ ""><FONT COLOR="RED"><B>&nbsp;#sWarn#<br></B></FONT>
				<CFELSEIF sMess NEQ ""><B>&nbsp;#sMess#</B></CFIF><br>
				<CFTRY>
					<CFQUERY NAME="autogen" DATASOURCE="#client.global_dsn#">
						SELECT FIELDNAME, SEEDKEY, CODELENGTH, WITHDATE FROM GSTAUTOGENFIELD
						WHERE TABLENAME = 'ECINBATCHAPPLY'
					</CFQUERY>
					<CFTRANSACTION ACTION="COMMIT"/>
					<CFCATCH TYPE="Database">
						<CFSET sWarn = "#CFCATCH.MESSAGE#" & "<BR>" & "#CFCATCH.DETAIL#">
						<CFTRANSACTION ACTION="ROLLBACK"/>
					</CFCATCH>
				</CFTRY>
				<CFIF autogen.RECORDCOUNT>
					<CFMODULE TEMPLATE="#client.common_path#autogenfield.cfm"
						SEEDKEY="#autogen.SEEDKEY#"
						CODELENGTH="#autogen.CODELENGTH#"
						COLUMNNAME="#autogen.FIELDNAME#"
						TABLENAME_FK="ECINBATCHAPPLY"
						DATASOURCE="#client.company_dsn#"
						WITHDATE="#autogen.WITHDATE#"
						SOURCETABLE="#GetData.TABLENAME_FK#">
				</CFIF>
				<CFQUERY NAME="GetData" DATASOURCE="#client.company_dsn#">
					SELECT A.PERSONNELIDNO, D.DOCNUMBER, C.TABLENAME_FK, B.BATCHID, D.DESCRIPTION
					FROM ECINBATCHEMPS A, ECRGBATCHAPPLY B, ECRGFORMS C, ECINBATCHAPPLY D
					WHERE 	(A.BATCHID = B.BATCHID) AND
						(B.BATCHID = D.BATCHID) AND
						(A.DOCNUMBER = D.DOCNUMBER) AND
						(B.BATCHID = C.FORMCODE)
						<CFIF isDefined("form.edtBatchNumber")> AND (D.DOCNUMBER = '#form.edtBatchNumber#')
						<CFELSE>AND (D.DOCNUMBER = '#AUTOGENVALUE#')</CFIF>
				</CFQUERY>
				<CFSET sBtnVal = "Add">
				<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 BGCOLOR="#client.color_grphead#" WIDTH="100%">
					<TR>
						<TD NOWRAP>
							<INPUT TYPE="submit" NAME="btnAdd" VALUE="#sBtnVal# Application" TITLE="Add new record" CLASS="bitbtn" #btnDisable#>
							<INPUT TYPE="submit" NAME="btnBackMenu" VALUE="Back" TITLE="Back" CLASS="bitbtn">
						<TD>
					</TR>
				</TABLE>
				<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 WIDTH="100%">
					<CFOUTPUT>
						<TR VALIGN="bottom">
							<TD WIDTH="20%">&nbsp;&nbsp;Record No.</TD>
							<TD WIDTH="1">&nbsp;*</TD>
							
							<TD WIDTH="30%">
							<CFIF autogen.RECORDCOUNT>
								<INPUT TYPE="text" VALUE="#AUTOGENVALUE#" NAME="edtBatchNumber" SIZE="40" readonly>
								<TD WIDTH="50%">&nbsp;</TD>
							<CFELSE>
								<INPUT TYPE="text" VALUE="" NAME="edtBatchNumber" SIZE="40" readonly><TD WIDTH="50%"><FONT COLOR="RED"><B>There's no configured Autogen value for Docnumber. Please contact your Administrator.</B></FONT></TD>
							</CFIF>	
							</TD>
						</TR>
						<TR VALIGN="bottom">
							<CFMODULE TEMPLATE="#client.common_path#cfm_htmlobject.cfm"
								TYPE="TEXT" ALIGN="LEFT"
								HTMLNAME="edtBatchDesc" VALUE=""
								DESCRIPTION="&nbsp;&nbsp;Description" MAXLENGTH = "30"
								REQUIRED="True" SIZE ="40" WIDTH4="20%"
								WITHFIELDDESC="true" WITHAUDITFIELD="true"
								READONLY="#isReadonly#" WIDTH="30%">
						</TR>
					</CFOUTPUT>
				</TABLE>
				<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Employee List">
					<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2 WIDTH="100%">
						<TR>
							<TD colspan=4>
								<INPUT TYPE="SUBMIT" NAME="btnAddEmployees" VALUE = "Add Employees" CLASS="bitbtn" #btnDisable#>&nbsp;
								<INPUT TYPE="SUBMIT" NAME="btnAddToRecord" VALUE = "Save Record" CLASS="bitbtn" DISABLED>&nbsp;
								<INPUT TYPE="SUBMIT" NAME="btnDeleteEmployee" VALUE = "Delete Selected" CLASS="bitbtn" DISABLED>&nbsp;
							</TD>
						</TR>
						<TR BGCOLOR="#client.color_tblhead#">
							<TD CLASS="boldwhite"><center>Apply Details</center></TD>
							<TD CLASS="boldwhite">&nbsp;</TD>
							<TD CLASS="boldwhite">#stheIDDesc#</TD>
							<TD CLASS="boldwhite">Last Name</TD>
							<TD CLASS="boldwhite">First Name</TD>
							<TD CLASS="boldwhite">Middle Name</TD>
							<TD CLASS="boldwhite">Cost Center Code</TD>
						</TR>
						<!--- ecinbatchemps --->
						<CFLOOP QUERY="GetData">
							<CFQUERY NAME="qryEmployeeMaster" DATASOURCE="#client.company_dsn#">
								SELECT PERSONNELIDNO, PERSONNELBADGENO, LASTNAME, FIRSTNAME, MIDDLENAME, COSTCENTERCODE
								FROM CMFPA
								WHERE 
									#stheID# = '#evaluate("GetData.PERSONNELIDNO")#'
							</CFQUERY>
							<TR>
								<TD WIDTH=2><CENTER><INPUT TYPE="CHECKBOX" NAME="chkEmps" VALUE="#GetData.PERSONNELIDNO#" #btnDisable# ONCLICK="javascript:chkBoxEnable();"></CENTER></TD>
								<TD><CENTER>&nbsp;<CFIF NOT isDefined("url.view")><a class="regular11" href="#getFileFromPath(getBaseTemplatePath())#?#urlVariables#&DOCNUMBER=#GetData.DOCNUMBER#&EMPLOYEEID=#evaluate("GetData." & stheID)#&edit=true"></CFIF>edit<CFIF NOT isDefined("url.view")></a></CFIF></CENTER></TD>
								<TD>&nbsp;<a class="regular11" href="#getFileFromPath(getBaseTemplatePath())#?#urlVariables#&EMPLOYEEID=#evaluate("GetData." & stheID)#&DOCNUMBER=#GetData.DOCNUMBER#&view=true">#evaluate("GetData." & stheID)#</a></TD>
								<TD>&nbsp;#qryEmployeeMaster.LASTNAME#</TD>
								<TD>&nbsp;#qryEmployeeMaster.FIRSTNAME#</TD>
								<TD>&nbsp;#qryEmployeeMaster.MIDDLENAME#</TD>
								<TD>&nbsp;#qryEmployeeMaster.COSTCENTERCODE#</TD>
							</TR>
						</CFLOOP>
						<TR BGCOLOR="#client.color_tblfoot#">
							<TD COLSPAN=7 HEIGHT=18 CLASS="boldwhite" HEIGHT=18>&nbsp;#GetData.RecordCount# records found.</TD>
						</TR>
					</TABLE>
				<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
			</CFOUTPUT>
			<CFOUTPUT>
				<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="eForm Details">
			</CFOUTPUT>
			<CFQUERY NAME="GetFields" DATASOURCE="#client.global_dsn#">
				SELECT COLUMNNAME, COLUMNDESC, COLUMNTYPE, COLUMNREQUIRED, SAMEROW, ISVISIBLEEFORM, ISEDITABLEEFORM, DEFAULTVALUE, HINT, DISPLAYWIDTH, PHYSICALWIDTH, PICKLIST, DISPLAYFORMAT
				FROM GRGBOSETABLEFIELDS
				WHERE TABLENAME = '#GetData.TABLENAME_FK#' AND ISVISIBLEEFORM = 'Y'
				ORDER BY COLUMNORDER ASC
			</CFQUERY>
			<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 WIDTH="100%">
				<CFOUTPUT>
					<TR VALIGN="bottom">
						<TD ALIGN="right"><IMG SRC="#client.image_path##session.site_ibose#"></TD>
						<TD NOWRAP CLASS="bold14" WIDTH="100%"><FONT FACE="Impact" SIZE="+2">#client.companyname#</FONT><BR>#GetData.DESCRIPTION#</TD>
					</TR>
				</CFOUTPUT>
			</TABLE>
			<TABLE BORDER=0 CELLSPACING=3 CELLPADDING=0 WIDTH="100%" BGCOLOR="#FFFFFF">
				<CFOUTPUT>
					<TR><TD>&nbsp;</TD>
					</TR>
					<CFSET sEntryValue = "">
					<CFLOOP QUERY="GetFields">
						<CFQUERY NAME="qryAutoGenFld" DATASOURCE="#client.global_dsn#">
							SELECT FIELDNAME FROM GSTAUTOGENFIELD
							WHERE TABLENAME = '#GetData.TABLENAME_FK#' AND FIELDNAME = '#COLUMNNAME#'
						</CFQUERY>
						<CFMODULE TEMPLATE="#client.common_path#cfm_bosesize.cfm" CURRENTSIZE=#DISPLAYWIDTH#>
						<CFIF NOT qryAutoGenFld.RECORDCOUNT AND COLUMNNAME NEQ "PERSONNELIDNO" AND COLUMNNAME NEQ "PERSONNELBADGENO">
							<CFMODULE TEMPLATE="#client.common_path#get_default_value.cfm" EntryValue="#DEFAULTVALUE#">
							<CFSET sEntryValue = sDefaultValue>
							<TR>
								<CFIF COLUMNREQUIRED EQ "Y">
									<CFSET isRequired = "true">
								<CFELSE>
									<CFSET isRequired = "false">
								</CFIF>
								<CFIF ISEDITABLEEFORM EQ "Y" AND NOT isDefined("url.view")>
									<CFSET isReadonly = "false">
								</CFIF>
								<CFIF lcase(COLUMNTYPE) EQ "ftCurrency">
									<CFMODULE TEMPLATE="#client.common_path#cfm_htmlobject.cfm"
										TYPE="TEXT" ALIGN="LEFT"
										HTMLNAME="edt#COLUMNNAME#" VALUE="#sEntryValue#"
										DESCRIPTION="&nbsp;&nbsp;#COLUMNDESC#" MAXLENGTH = "15"
										REQUIRED="#isRequired#" SIZE ="15"
										WITHFIELDDESC="true" WITHAUDITFIELD="true"
										READONLY="#isReadonly#" HINT="#HINT#"
										PARAMETERS2=""onBlur="formatNumber(this)""">
								<CFELSEIF lcase(COLUMNTYPE) EQ "ftfloat" OR lcase(COLUMNTYPE) EQ "ftsmallint" OR lcase(COLUMNTYPE) EQ "ftinteger">
									<CFMODULE TEMPLATE="#client.common_path#cfm_htmlobject.cfm"
										TYPE="TEXT"  ALIGN="LEFT"
										HTMLNAME="edt#COLUMNNAME#" VALUE="#sEntryValue#"
										DESCRIPTION="&nbsp;&nbsp;#COLUMNDESC#" MAXLENGTH = "15"
										REQUIRED="#isRequired#"  SIZE ="15"
										WITHFIELDDESC="true" WITHAUDITFIELD="true"
										READONLY="#isReadonly#" HINT="#HINT#"
										PARAMETERS2="onkeyup=""CheckDigit('0123456789', this)""">
								<CFELSEIF lcase(COLUMNTYPE) EQ "ftdatetime">
									<CFMODULE TEMPLATE="#client.common_path#cfm_htmlobject.cfm"
										TYPE="DATE" ALIGN="LEFT"
										HTMLNAME="edt#COLUMNNAME#" VALUE="#sEntryValue#"
										DESCRIPTION="&nbsp;&nbsp;#COLUMNDESC#"
										REQUIRED="#isRequired#"
										WITHFIELDDESC="true" WITHAUDITFIELD="true"
										READONLY="#isReadonly#" HINT="#HINT#"
										PARAMETERS="frmBatchApp|">
								<CFELSEIF lcase(COLUMNTYPE) EQ "ftmemo">
									<CFMODULE TEMPLATE="#client.common_path#cfm_htmlobject.cfm"
										TYPE="TEXTAREA" ALIGN="LEFT"
										HTMLNAME="edt#COLUMNNAME#" VALUE="#sEntryValue#"
										DESCRIPTION="&nbsp;&nbsp;#COLUMNDESC#" SIZE="#BOSESIZE#"
										REQUIRED="#isRequired#"
										WITHFIELDDESC="true" WITHAUDITFIELD="true"
										READONLY="#isReadonly#" HINT="#HINT#">
								<CFELSEIF lcase(COLUMNTYPE) EQ "ftgraphic" OR lcase(COLUMNTYPE) EQ "ftblob">
									interface not supported.
								<CFELSEIF lcase(COLUMNTYPE) EQ "ftcombo">
									<CFSET isChecked="false">
									<TD style="padding-right:5px;" ALIGN="left" NOWRAP WIDTH="100">&nbsp;&nbsp;#COLUMNDESC#</TD><TD ><CFIF COLUMNREQUIRED EQ "Y">&nbsp;*&nbsp;</CFIF></TD>
									<TD NOWRAP>
									<CFIF ListLen(PICKLIST) LTE 3>
										<CFLOOP INDEX="x" LIST="#PICKLIST#">
											<INPUT NAME="edt#COLUMNNAME#" <CFIF Trim(x) EQ Trim(sEntryValue)>CHECKED</CFIF> TYPE="radio" VALUE="#Trim(x)#" #btnDisable#>#x#
										</CFLOOP>
									</TD>
									<CFELSE>
											<CFSET lstParam = "">
											<SELECT NAME="edt#COLUMNNAME#" SIZE="1" #btnDisable#>
												<OPTION VALUE="">&nbsp;&nbsp;</OPTION>
												<CFLOOP INDEX="ListElement" LIST="#PICKLIST#" DELIMITERS=",">
													<CFIF #sEntryValue# EQ #ListElement#>
														<OPTION SELECTED VALUE="#ListElement#">#ListElement#</OPTION>
													<CFELSE>
														<OPTION VALUE="#ListElement#">#ListElement#</OPTION>
													</CFIF>
												</CFLOOP>
											</SELECT>
										</TD>
									</CFIF>
								<CFELSE>
									<CFQUERY NAME="GetLookup" DATASOURCE="#client.global_dsn#">
										SELECT A.*, B.LEVELID
										FROM GSTLOOKUP A, GRGBOSETABLE B
										WHERE
											(A.MASTERTABLE = '#GetData.TABLENAME_FK#') AND
											(A.MASTERFIELD = '#COLUMNNAME#') AND
											(A.LOOKUPTABLE = B.TABLENAME)
											</CFQUERY>
									<CFIF GetLookup.RecordCount>
										<CFMODULE TEMPLATE="#client.common_path#cfm_htmlobject.cfm"
											TYPE="LOOKUP" ALIGN="LEFT"
											HTMLNAME="edt#COLUMNNAME#" VALUE="#sEntryValue#"
											DESCRIPTION="&nbsp;&nbsp;#COLUMNDESC#"
											REQUIRED="#isRequired#"
											WITHFIELDDESC="true" WITHAUDITFIELD="true"
											READONLY="#isReadonly#" HINT="#HINT#"
											PARAMETERS="&nbsp;|javascript:ShowLookup('#GetLookup.LEVELID#','#GetLookup.LOOKUPTABLE#','edt#COLUMNNAME#','frmBatchApp',
											'#GetLookup.LOOKUPKEYFIELD#~#GetLookup.LOOKUPKEYFIELD#~ftString,#GetLookup.LOOKUPRESULTFIELD#~#GetLookup.LOOKUPRESULTFIELD#~ftString,'
											,'#GetLookup.LOOKUPKEYFIELD#','edt#COLUMNNAME#Desc','#GetLookup.LOOKUPRESULTFIELD#','#GetLookup.FILTERFIELD#','#GetLookup.FILTERVALUE#')">
									<CFELSE>
										<CFIF DISPLAYFORMAT NEQ "">
											<CFMODULE TEMPLATE="#client.common_path#cfm_htmlobject.cfm"
												TYPE="TEXT"  ALIGN="LEFT"
												HTMLNAME="edt#COLUMNNAME#" VALUE="#sEntryValue#"
												DESCRIPTION="&nbsp;&nbsp;#COLUMNDESC#" MAXLENGTH = "#PHYSICALWIDTH#"
												REQUIRED="#isRequired#"  SIZE ="#BOSESIZE#"
												WITHFIELDDESC="true" WITHAUDITFIELD="true"
												READONLY="#isReadonly#" HINT="#HINT#"
												PARAMETERS2 = "onBlur=""javascript: validateMasked(this,'#GetFields.DISPLAYFORMAT#')""" WIDTH4 = "150">
										<CFELSE>
											<CFMODULE TEMPLATE="#client.common_path#cfm_htmlobject.cfm"
												TYPE="TEXT"  ALIGN="LEFT"
												HTMLNAME="edt#COLUMNNAME#" VALUE="#sEntryValue#"
												DESCRIPTION="&nbsp;&nbsp;#COLUMNDESC#" MAXLENGTH = "#PHYSICALWIDTH#"
												REQUIRED="#isRequired#"  SIZE ="#BOSESIZE#"
												WITHFIELDDESC="true" WITHAUDITFIELD="true"
												READONLY="#isReadonly#" HINT="#HINT#"
												WIDTH4 = "150">
										</CFIF>
									</CFIF>
								</CFIF>
							<CFELSE>
								<TD style="padding-right:5px;" ALIGN="left" NOWRAP WIDTH="150">&nbsp;&nbsp;#COLUMNDESC#</TD><TD ><CFIF COLUMNREQUIRED EQ "Y">&nbsp;*&nbsp;</CFIF></TD>
									<TD NOWRAP><INPUT TYPE="TEXT" SIZE="#BOSESIZE#" READONLY></TD>
							</CFIF>
						</TR>
					</CFLOOP>
				</CFOUTPUT>
			</TABLE>
			<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
		<!---</FORM>--->
	</CFIF>
	<CFIF sFieldWthFormat NEQ "">
		<CFOUTPUT>
		<SCRIPT Language="javascript">
			<CFLOOP LIST="#sFieldWthFormat#" INDEX="x">
				formatNumber(document.frmBatchApp.#x#)
			</CFLOOP>
		</SCRIPT>
		</CFOUTPUT>
	</CFIF>
</FORM>
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="FALSE">
